package com.qf.config;

import com.qf.consants.RabbitMQConstants;
import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public FanoutExchange goodsExchange(){
        return new FanoutExchange(RabbitMQConstants.GOODS_EXCAHNGE,true,false);
    }

    @Bean
    public Queue goodsQueueItem(){
        return new Queue(RabbitMQConstants.GOODS_QUEUE_ITEM,true,false,false);
    }

    @Bean
    public Binding goodsQueueItemToGoodsExchange(){
        return BindingBuilder.bind(goodsQueueItem()).to(goodsExchange());
    }
}
